


ALTER     proc update_vendor_location_types

@location_type varchar(50), @vendor_id int, @address_id int, 
@contact_person varchar(50), @vendor_name varchar(50)

as

declare @location_type_exists int

if(@location_type is not null or @location_type <> '')
select @location_type_exists = (select count(*) from location where Vendor_ID = @vendor_id and
L_Type = @location_type and Address_ID = @address_id)

if(@location_type_exists = 0)
begin
insert into Location (Address_ID,Vendor_Id,L_Contact_Person,L_Type,L_Vendor_Name,L_Is_Deleted)
	values(@address_id,@vendor_id,@contact_person,@location_type,@vendor_name,'N')
end
else
begin
update Location set L_Is_Deleted = 'N', L_Contact_Person = @contact_person
	 where Vendor_ID = @vendor_id and
	L_Type = @location_type and Address_ID = @address_id
end





